<?php
#--------------------------------------------------
# LOAD TEAMS
#--------------------------------------------------
include_once ("./dataAccess/classes/Team.php5");
include_once ("./dataAccess/dao/TeamDAO.php5");

$teamDao = new TeamDAO();

// aktuelles jahr
$year = date("Y");
while (empty($teams) && $year > 1995) {
	$teams = $teamDao->findBySaison($year--);
}
if (!empty($teams)){
	$i = 0;	
	foreach ($teams as $team){
		$img = strtolower($team->name);
		if (!empty($team->suffix)){
			$img .= "_".$team->suffix;
		}		
		$teamLink .= sprintf("teams[%d]='<a href=\"team.php5?team_id=%d\"><img src=\"images/navi/%s.gif\" border=\"0\"></a>';\n", $i++,$team->id, $img);
	}
} else {
	$teamLink = "";
}
$t->set_var(array (
		"TEAMS" => $teamLink));
#--------------------------------------------------
# LOAD SPONSOREN
#--------------------------------------------------
include_once ("./dataAccess/classes/Sponsor.php5");
include_once ("./dataAccess/dao/SponsorDAO.php5");

$dao = new SponsorDAO();
$sponsoren = $dao->findAllSortedByPos();
if (!empty($sponsoren)){
	foreach ($sponsoren as $sponsor){
		$img = sprintf("<img src=\"images/sponsors/%s\" border=\"0\" width=\"120px\" title=\"%s\">", 
		$sponsor->foto, $sponsor->name);
		$home = $sponsor->homepage;
		if ($home != "http://" && strlen($home) > 0){
			$img = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $home, $img);
		}
		// umbruch
		$img = "<p>".$img."</p>";
		$sponsors .= $img;
	}
}
$t->set_var(array (
		"SPONSOREN" => $sponsors));

#--------------------------------------------------
# CREATE TICKER
#--------------------------------------------------
$ticker = "";

$sql = $svo->doSQL("select * from " . $table['Berichte'] . " WHERE cat='TICKER' order by date desc limit 1;");

while ($tupel = $svo->getRecordset($sql)) {
	$t->set_var(array (
		"TICKER" => substr($tools->html_replace($tupel['text']
	), 0, 250)));
	$ticker .= $t->parse("", "ticker", true);

}
?>
